package com.linjiahao.eduservice.controller;


import com.linjiahao.commonutils.ResultMap;
import com.linjiahao.eduservice.service.EduSubjectService;
import com.linjiahao.eduservice.vo.OneSubjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2020-08-24
 */
@Api(description="课程分类管理")
@RestController
@RequestMapping("/eduservice/subject")
public class EduSubjectController {

    @Autowired
    private EduSubjectService subjectService;

    //添加课程分类
    @ApiOperation(value = "Excel批量导入")
    @PostMapping("addSubject")
    public ResultMap addSubject(MultipartFile file) {

        subjectService.importSubjectData(file,subjectService);
        return ResultMap.ok();
    }

    @ApiOperation(value = "数据列表")
    @GetMapping("")
    public ResultMap nestedList(){
        List<OneSubjectVo> subjectNestedVoList = subjectService.nestedList();
        return ResultMap.ok().data("items", subjectNestedVoList);
    }
}

